<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<style>
    #div {
        width: 200px;
    }
</style>
<script>
    // var div = document.getElementById("div");
    // var w = div.offsetWidth;
    // alert(w)
    function sub() {
        var T = document.querySelector('#frm');
        var D = document.querySelector('input[type=text]');
        alert(D.value);
    }
</script> 

<body>
    <form id="frm"  method="GET">
        <input type="text" name="uername" id="name">
        <input type="submit" value="点击" onclick="sub()" />
    </form>
</body>

</html>